<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('资产信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: cropbox-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <div style="text-align: center;border: 1px solid #aaa;height: 200px;line-height: 200px;">
            <img th:src="${imgUrl}" class="img" height="180" style="max-width: 100%">
            <div class="spinner">暂无图片...</div>
        </div>
        <p class="gd col-sm-12" style="margin-top: 3px" >
            <a class="btn btn-info btn-xs" style="height: 30px;line-height: 25px" href="javascript:void(0)" onclick="showImg()">更多</a>
        </p>
        <form class="form-horizontal m" id="form-inventory-edit" th:object="${assetDetail}">
            <input name="id" th:value="*{id}" type="hidden" id="assetId">
            <input name="No" th:value="*{No}" type="hidden">
            <input name="deptId" type="hidden" th:field="*{deptId}" id="deptId"/>
            <div class="form-group">
                <label class="col-sm-4">资产序号：</label>
                <span th:hidden="${allFlag}" class="col-sm-6" th:text="*{id+'-'+No}"></span>
                <span th:hidden="${!allFlag}" class="col-sm-6" th:text="*{id}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">资产名称：</label>
                <span class="col-sm-6" th:text="*{assetName}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">卡片编号：</label>
                <span class="col-sm-6" th:text="*{assetNo}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">资产编码：</label>
                <span class="col-sm-6" th:text="*{assetCode}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">资产类别：</label>
                <span class="col-sm-6" th:text="*{@dict.getLabel('asset_type',assetType)}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">所属组织：</label>
                <span class="col-sm-6" th:text="*{companyName}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">规格：</label>
                <span class="col-sm-6" th:text="*{specifications}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">型号：</label>
                <span class="col-sm-6" th:text="*{assetModel}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">单位：</label>
                <span class="col-sm-6" th:text="*{@dict.getLabel('asset_unit',assetUnit)}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">价格：</label>
                <span class="col-sm-6" th:text="*{price}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">管理部门：</label>
                <span class="col-sm-6" th:text="*{manageDeptName}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">管理人：</label>
                <span class="col-sm-6" th:text="*{manageUser}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">投用时间：</label>
                <span class="col-sm-6" th:text="${#dates.format(assetDetail.useDate, 'yyyy-MM-dd')}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">录入时间：</label>
                <span class="col-sm-6" th:text="${#dates.format(assetDetail.putDate, 'yyyy-MM-dd')}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">消耗类型：</label>
                <span class="col-sm-6" th:text="*{@dict.getLabel('consume_type',consumeType)}"></span>
            </div>
            <!--<div class="form-group">-->
                <!--<label class="col-sm-4">使用部门：</label>-->
                <!--<div class="col-sm-8">-->
                    <!--<div class="input-group">-->
                        <!--<input name="deptName" onclick="selectDeptTreeUse()" id="deptName" type="text" th:field="*{useDeptName}" placeholder="请选择使用部门" class="form-control" required>-->
                        <!--<span class="input-group-addon"><i class="fa fa-search"></i></span>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-4">使用部门：</label>
                <span class="col-sm-6" th:text="*{useDeptName}"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-4">使用人：</label>
                <span class="col-sm-6" th:text="*{useUser}"></span>
            </div>
            <!--<div class="form-group">-->
                <!--<label class="col-sm-4">使&nbsp&nbsp用&nbsp人：</label>-->
                <!--<div class="col-sm-6">-->
                    <!--<select id="useUser" th:field="*{useUser}" name="useUser" class="form-control select2-multiple">-->
                        <!--<option value=""></option>-->
                        <!--<option th:each="useUser : ${useUserList}" th:text="${useUser.userName}" th:value="${useUser.userId}"></option>-->
                    <!--</select>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="form-group">-->
                <!--<label class="col-sm-4">使用地点：</label>-->
                <!--<div class="col-sm-6">-->
                    <!--<input name="address" th:field="*{address}" class="form-control" type="text">-->
                <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-4">使用地点：</label>
                <span class="col-sm-6" th:text="*{address}"></span>
            </div>
            <!--<div class="form-group">-->
                <!--<label class="col-sm-4">资产情况：</label>-->
                <!--<div class="col-sm-6">-->
                    <!--<select name="useStatus" th:field="*{useStatus}" class="form-control select2-multiple" th:with="type=${@dict.getType('use_status')}" required>-->
                        <!--<option value="">请选择</option>-->
                        <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
                    <!--</select>-->
                <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-4">资产情况：</label>
                <span class="col-sm-6" th:text="*{@dict.getLabel('use_status',useStatus)}"></span>
            </div>
            <!--<div class="form-group">-->
                <!--<label class="col-sm-4">数量：</label>-->
                <!--<div class="col-sm-6">-->
                    <!--<input name="amount" th:field="*{amount}" class="form-control" type="text" required>-->
                <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-4">数量：</label>
                <span class="col-sm-6" th:text="*{amount}"></span>
            </div>
            <div class="form-group"  th:hidden="${repeatFlag||allFlag||lostScrapFlag}">
                <label class="col-sm-4">是否相符：</label>
                <div class="col-sm-6">
                    <label class="radio-box"> <input type="radio"  name="agreementStatus" value="1" required /> 相符 </label>
                    <label class="radio-box"> <input type="radio"  name="agreementStatus" value="0" required /> 不相符 </label>
                </div>
            </div>
            <div class="form-group"  th:hidden="${lostScrapFlag}">
                <label class="col-sm-4">是否报废：</label>
                <div class="col-sm-6">
                    <label class="radio-box"> <input type="radio" name="scrapStatus" value="0"/> 否 </label>
                    <label class="radio-box"> <input type="radio" name="scrapStatus" value="1" /> 是 </label>
                </div>
            </div>
            <div class="form-group" th:hidden="${allFlag}">
                <label class="col-sm-4">备注：</label>
                <div class="col-sm-6">
                    <textarea name="remark" rows="3"  class="form-control"></textarea>
                </div>
            </div>
            <a class="btn btn-success btn-xl" href="javascript:void(0)" th:hidden="${lostScrapFlag}" onclick="submitHandler()">保存</a>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: cropbox-js" />
    <script type="text/javascript">
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
        var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os';
        var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
        var bIsUc = sUserAgent.match(/ucweb/i) == 'web';
        var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
        var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
        var bIsAndroid = sUserAgent.match(/android/i) == 'android';
        var isNotPc;
        if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM || bIsAndroid ){
            isNotPc = true
            $("#toolbar").hide();
        }else{
            isNotPc = false
        }
        var cropper;
        var id='[[${assetDetail.id}]]';
        var prefix = ctx + "inventory/inventory";
        var imgUrl = '[[${imgUrl}]]';
        var qrCodeUrl = '[[${qrCodeUrl}]]';
        var allFlag = [[${allFlag}]];
        var repeatFlag = [[${repeatFlag}]];
        var lostScrapFlag = [[${lostScrapFlag}]];
        var imgCount = '[[${assetDetail.imgCount}]]';
        if ($.common.isEmpty(imgUrl)){
            $(".img").hide();
        }else {
            $(".spinner").hide();
        }
        if (imgCount<2){
            $(".gd").hide();
        }
        $("#form-inventory-edit").validate({
            focusCleanup: true
        });
        if (allFlag||lostScrapFlag){
            $(".btn-xl").hide();
        }
        if(repeatFlag){
            $.modal.alertWarning("资产已盘点！")
        }
        if(lostScrapFlag){
            $.modal.alertWarning("该资产已遗失报废处理！")
        }
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-inventory-edit').serialize(),function(data){
                    if (data.code==0){
                        window.location=qrCodeUrl+"/inventory/inventory/inventory/"+data.data;
                    }else{
                        $.modal.alertWarning(data.msg);
                    }
                });
            }
        }
        /*选择使用部门树*/
        function selectDeptTreeUse() {
            var deptId = $.common.isEmpty($("#deptId").val()) ? "100" : $("#deptId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmitUse
            };
            $.modal.openOptions(options);
        }
        function doSubmitUse(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#deptId").val(body.find('#treeId').val());
                $("#deptName").val(body.find('#treeName').val());
                layer.close(index);
            }
            $("#useUser").empty();
            $.post(ctx +"system/user/getUserByDept",{deptId:$("#deptId").val()},function (data) {
                $("#useUser").append('<option value=""></option>');
                $.each(data,function (index,p) {
                    $("#useUser").append('<option value="'+p.userId+'">'+p.userName+'</option>');
                })
            });
        }
        function showImg() {
            if(isNotPc) {
                $.modal.openFull('资产图片',ctx + "asset/assetDetail/showImg/"+id+","+false);
            }else {
                $.modal.open('资产图片', ctx + "asset/assetDetail/showImg/"+id+","+false);
            }
        }
    </script>
</body>
</html>